﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using WinPhoneVoiceCommands.Resources;

using Windows.Phone.Speech.VoiceCommands;
using Windows.Phone.Speech.Recognition;

namespace WinPhoneVoiceCommands
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            RegisterVoiceCommands();
        }

        private async void RegisterVoiceCommands()
        {
            await VoiceCommandService.InstallCommandSetsFromFileAsync(
                        new Uri("ms-appx:///vcd.xml", UriKind.RelativeOrAbsolute));
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ModifyPhraseList("MyVoiceCommands", "operand1");
            ModifyPhraseList("MyVoiceCommands", "operand2");
        }

        private async void ModifyPhraseList(string commandsetname,string  phraselistname)
        {
            string[] numbers = new string[]{"1","2","3","4","5","6","7","8","9","10"};
            var vcs = VoiceCommandService.InstalledCommandSets[commandsetname];
            await vcs.UpdatePhraseListAsync(phraselistname, numbers);
        }
        

    }
}